package com.wjh.anyview.controller;

import com.wjh.anyview.entity.bo.clazzServiceBo.StudentClazzBo;
import com.wjh.anyview.entity.bo.examServiceBo.MarkBo;
import com.wjh.anyview.entity.dto.CommonResult;
import com.wjh.anyview.entity.po.Clazz;
import com.wjh.anyview.entity.po.Institution;
import com.wjh.anyview.service.ClazzService;
import com.wjh.anyview.service.InstitutionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjh
 * @date 2021/10/9 18:39
 * @Package com.wjh.anyview.controller
 */
@RestController
@RequestMapping("/api/management")
public class ManagementController {
    @Resource
    private InstitutionService institutionService;

    @Resource
    private ClazzService clazzService;

    @PostMapping("/saveInstitution")
    @PreAuthorize("hasAuthority('/saveInstitution')")
    public CommonResult<?> saveInstitution(@RequestBody Institution institution) {
        return institutionService.saveInstitution(institution);
    }

    @PostMapping("/saveClazz")
    @PreAuthorize("hasAuthority('/saveClazz')")
    public CommonResult<?> saveClazz(@RequestBody Clazz clazz) {
        return clazzService.saveClazz(clazz);
    }

    @PostMapping("/updateStudentClazz")
    @PreAuthorize("hasAuthority('/updateStudentClazz')")
    public CommonResult<?> updateStudentClazz(@RequestBody StudentClazzBo studentClazzBo) {
        return clazzService.updateStudentClazz(studentClazzBo);
    }

    @PostMapping("/deleteClazzById")
    @PreAuthorize("hasAuthority('/deleteClazzById')")
    public CommonResult<?> deleteClazzById(@RequestParam("clazzId") Long clazzId){
        return clazzService.deleteClazzById(clazzId);
    }

}
